package main

import (
	"flag"
	"jkgo/jk/jklog"
	"jkgo/jkbase"
	"findService/ss/jkstatus/jkstatus"
)

type StatusArgs struct {
	jkbase.ConfigBaseArgs
}

var st_args StatusArgs

var (
	cmd      = flag.String("cmd", "run", "run/install/remove service")
	debug    = flag.Bool("d", false, "debug log out")
	conffile = flag.String("config", "etc/findyouwant/jkstatus.json", "Config file")
)

func start() {

	//jkstatus.Start(*address, *port, true)
	jklog.L().Infof("jkstatus started with [%s:%d]\n", st_args.ClientAddr, st_args.ClientPort)
	jkstatus.StartIoT(st_args.ClientAddr, st_args.ClientPort)
}

func main() {
	flag.Parse()

	err := jkbase.CMConfigFile(*conffile, &st_args)
	if err != nil {
		jklog.L().Errorln(err)
		return
	}

	jklog.L().InitLog(st_args.LogFile)
	if *debug {
		jklog.L().SetLevel(jklog.LEVEL_ALL)
	}
	jklog.L().Infoln("jkstatus program started")
	jklog.L().Debugln(st_args)

	_, err = jkbase.InitProgramRun("jkstatus", "jk status program", start)
	if err != nil {
		jklog.L().Errorln(err)
		return
	}
	jklog.L().Infoln("jkstatus exit...")
}
